/**
 * 1
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-3 下午3:25
 */

#include <iostream>

using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        string s1 = s.substr(0, 2);
        int hour = stoi(s1);
        hour = (hour + 16) % 24;
        printf("%02d", hour);
        cout << s.substr(2, s.size()) << endl;
    }
    return 0;
}